import React, { useEffect, useState } from 'react'
import "./css/user.css"
import axios from '../../http/index'
import { Link } from 'react-router-dom'
export default function Userlabel() {
    let [Box, setBox] = useState<any>("")
    let loaduserinfo = async () => {
        let res = await axios("/egg/userinfo")
        console.log(res, "---------1")
        if (res.data.code == 2000) {
            let u = <div>
                <span>{res.data.info.nickname}</span>
                <img className='userimg' src={`${(axios as any).base}${res.data.info.img}`} alt="" />
            </div>
            setBox(u)
        }
        else {
            setBox(<Link to="/jack/login">登录</Link>)
        }
    }
    useEffect(() => {
        loaduserinfo()
    }, [])

    return (
        <div>
            {Box}
        </div>
    )
}
